package com.cs.base.room;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

/**
 * @ClassName: MapRoomDao
 * @Date: 2021/6/11
 * @Author: CS
 * @Description:
 */
@Dao
public interface MapRoomDao {
    @Insert
    void insertMapRoom(MapRoom... rooms);

    @Update
    void updateMapRoom(MapRoom... rooms);

    @Delete
    void deleteMapRoom(MapRoom... rooms);

    @Query("UPDATE MapRoom SET time = :time AND value = :value WHERE `key` = :key")
    void updateMapRoomByKey(String time, String value, String key);

    @Query("DELETE FROM MapRoom WHERE `key` IN (:keys)")
    void deleteMapRoomByKeys(String... keys);

    @Query("DELETE FROM MapRoom")
    void deleteAllMapRoom();

    @Query("SELECT * FROM MapRoom WHERE `key` LIKE :key")
    MapRoom getMapRoomByKey(String key);

    @Query("SELECT * FROM MapRoom WHERE `key` IN (:keys)")
    List<MapRoom> getMapRoomByKeys(String... keys);

    @Query("SELECT * FROM MapRoom")
    LiveData<List<MapRoom>> getAllMapRoom();
}
